package com.ccx.coachsite.downloadmgr;

import android.content.Context;
import android.content.Intent;

import com.ccx.coachsite.api.CoachSiteSoftMgrApiAccessor;
import com.ccx.coachsite.model.ServerDetailResult;
import com.ccx.coachsite.ui.softmgr.SoftInfo;

public class DownloadTool {

	public static final String SOFT_FLAG_DEFALUT_VALUE = "1";
	
	public static final String SOFT_FLAG = "softFlag";
	
	/**
	 * 默认是天翼空间的软件
	 * return 1为应用汇
	 */
	public static String getSoftFlag(String flag){
		
		return flag==null?SOFT_FLAG_DEFALUT_VALUE:flag;
	}
	
	public static void downSoftItemByID(final Context mContext, final int softID){
		
		new Thread(new Runnable() {
			
			@Override
			public void run() {
				
				ServerDetailResult<SoftInfo> serverDetailResult = CoachSiteSoftMgrApiAccessor.getSoftAppDetail(softID, "-1", DownloadTool.getSoftFlag(null));
	      		if (serverDetailResult.detailItem==null) {
	      			 return ;
	      		}
				
				Intent intent=new Intent(mContext,DownloadService.class);
				intent.putExtra(DownloadItem.EXTRA_ME, serverDetailResult.detailItem);
				mContext.startService(intent);
			}
		}).start();
	}
}
